# coding=utf-8
import requests
from retrying import retry
headers = {"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1"
           }
@retry(stop_max_attempt_number=3)
def _parse_url(url):
    print("*"*100)
    response = requests.get(url,headers=headers,timeout=3)
    #print(response.content.decode())
    return response.content.decode()
def parse_url(url):
    try:
        html =_parse_url(url)
    except:
        html = None
    return html
if __name__ == '__main__':
    url ="http://www.baidu.com"
    print(parse_url(url)[:100])

